import utils from '../../utils';

const LOAD_DATA = 'grade/LOAD_DATA';

const initialState = {
    data: [],
    loadover: false
};

export default function reducer(state = initialState, action = {}) {
    switch (action.type) {
        case LOAD_DATA:
            return {
                ...state,
                data: action.data,
                loadover: true
            };
        default:
            return state;
    }
}

export const loadData = utils.createAction(
    LOAD_DATA,
    ({query, ctxCookie = ''} = {}) => utils.get('/api/grade', null, ctxCookie)
);
